#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

int main()
{
	int oldfd = open("log.txt", O_WRONLY | O_CREAT, 0666);
	if (oldfd < 0)
	{
		perror("oldfd error");
		return 1;
	}

	close(1);
	dup2(oldfd, 1);
	printf("hello world!\n");
	fprintf(stdout, "hello linux!\n");


	return 0;
}
